package zozopo.attendance;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import zozopo.attendance.operations.OperatorAttendanceOS;
import zozopo.attendance.operations.OperatorAttendanceTB;
import zozopo.background.operator.operations.OperatorOS;
import zozopo.background.operator.operations.OperatorTB;
import zozopo.background.operator.operations.OperatorlimitedTB;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class InfoOperatorAction extends ActionSupport implements Action,SessionAware{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private static final String limitedCode ="ATTENDANCE.OPERATOR";
	
	//传入参数
	private int operatorid;

 
	//传出参数
	OperatorAttendanceTB operatorofattendance;
	
	OperatorTB operator;
	
	private Map<Object, Object> session;
	public void setSession(Map arg0) {
		// TODO Auto-generated method stub
		session = arg0;
	}
	public String execute(){
		
		OperatorAttendanceOS operatorOfAttendanceOS = new OperatorAttendanceOS();
		OperatorOS operatorOS = new OperatorOS(operatorOfAttendanceOS.getConn());
		//operatorofattendance = operatorOfAttendanceOS.get(operatorid);

		operator = operatorOS.getInfo(operatorid);
		operatorofattendance = operatorOfAttendanceOS.getInfoByOperatorid(operatorid);

		operatorOfAttendanceOS.releaseConnection();
		
		return SUCCESS;
		
	}

	public void validate() {
		//权限处理
		
		OperatorTB operator = (OperatorTB)session.get("operatorInfo"); 
	
		if(operator == null){
			addFieldError("errormessage",getText("operator.timeoutornotlogin"));
			return ; 
		} 
		//用户权限
		Map<String,OperatorlimitedTB> operatorlimitedMap = (Map<String,OperatorlimitedTB>)session.get("operatorlimitedMap");
		
		if(operatorlimitedMap.get(limitedCode) == null){
			addFieldError("errormessage","用户没有添加售后信息权限.");
			return;
		}
	}
	
	
	
	public static String getLimitedcode() {
		return limitedCode;
	}

}
